<template>
  <div id="JDJGPDFNew">
    <!-- <div class="content">
  <div class="list"> -->
    <van-form validate-first>
      <p class="subTitle"><span class="line"></span>鉴定情况</p>
      <van-radio-group v-model="houseRemoldAuthSituation.isAuth" >
        <div v-for="(items,index) in XCDC" :key="index" style="padding-top: 10px">
          <van-radio v-if="!items.child" class="vanCheckbox"  :name="items.value" label-disabled shape="square">
            {{ items.name }}
          </van-radio>
          <template v-if="items.child" >
            <span>{{ items.name }}</span>
            （<van-radio v-for="(ite,ind) in items.child" :key="ind" :name="ite.value" shape="square"
                        style="display: inline-flex">{{ ite.name }}
          </van-radio>）
          </template>
        </div>
      </van-radio-group>
      <p class="subTitle"><span class="line"></span>鉴定基本信息</p>
      <div>
        <!-- <van-field :readonly='isread' clickable name="picker" v-model="sexName" label="性别" placeholder="请选择性别" @click="ENUM.XB = true" /> -->
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.authProjectName" label="工程名称" placeholder="请填写工程名称" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.peleaseUnit" label="委托单位" placeholder="请填写委托单位" />
        <!-- <van-field :readonly="isread" v-model="SHOWData[0].F_BGRQ" label="报告日期" placeholder="请填写报告日期" /> -->
        <van-field readonly clickable name="datetimePicker" :value="houseRemoldAuthSituation.authReportDate" label="报告日期"
                   placeholder="请填写报告日期" @click="showPickerq1 = true" />
        <van-popup v-model="showPickerq1" position="bottom">
          <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPickerq1 = false"
                               @confirm="onConfirmRQ1" />
        </van-popup>
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.appraiseUnitName" label="鉴定公司名称" placeholder="请填写鉴定公司名称" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.appraisePeopleName" label="查勘、鉴定人员" placeholder="请填写查勘、鉴定人员" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.reportWriteUserName" label="报告编写人" placeholder="请填写报告编写人" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.checkUserName" label="审核人" placeholder="请填写审核人" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.approvedUserName" label="批准人" placeholder="请填写批准人" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.address" label="地址" placeholder="请填写地址" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.phone" label="电话" placeholder="请填写电话" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.postCode" label="邮编" placeholder="请填写邮编" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.fax" label="传真" placeholder="请填写传真" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.reportNo" label="报告编号" placeholder="请填写报告编号" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.houseAddress" label="房屋地址" placeholder="请填写房屋地址" />
        <van-field clickable :readonly="isread" :value="houseRemoldAuthSituation.houseUse | inUseName(ENUM.FWYTARR)" label="房屋用途"
                     placeholder="请选择房屋用途" @click="ENUM.FWYT = true" />
          <van-popup v-model="ENUM.FWYT" position="bottom" get-container="#popup">
            <van-picker show-toolbar :columns="ENUM.FWYTARR" value-key="DICNAME" @confirm="confirmFWYT"
                        @cancel="ENUM.FWYT = false" />
          </van-popup>
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.buildYear" label="建造年份" placeholder="请填写建造年份" />
        <van-field readonly clickable name="picker" :value="houseRemoldAuthSituation.structureType | inUseName(ENUM.JGLXARR)"
                   label="结构类型" placeholder="请填写结构类型" @click="ENUM.JGLX = true"
                   :rules="[{ required: true, message: '结构类型' }]" />
        <van-popup v-model="ENUM.JGLX" position="bottom" get-container="#popup">
          <van-picker show-toolbar :columns="ENUM.JGLXARR" value-key="DICNAME" @confirm="confirmJGLX"
                      @cancel="ENUM.JGLX = false" />
        </van-popup>
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.buildArea" label="建筑面积(㎡)" placeholder="请填写建筑面积" />

        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.floorArea" label="占地面积(㎡)" placeholder="请填写占地面积" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.houseTo" label="房屋朝向" placeholder="请填写房屋朝向" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.floors" label="层数" placeholder="请填写层数" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.planaStructure" label="平面结构" placeholder="请填写平面结构" />
        <van-field readonly clickable name="datetimePicker" :value="houseRemoldAuthSituation.createDate" label="填写日期"
                   placeholder="请填写日期" @click="showPickerq2 = true" />
        <van-popup v-model="showPickerq2" position="bottom">
          <van-datetime-picker v-model="currentDate" type="date" title="选择年月日" @cancel="showPickerq2 = false"
                               @confirm="onConfirmRQ2" />
        </van-popup>
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.bearingSystem" label="承重体系" placeholder="请填写承重体系" />

        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.roomSurface" label="房面形式" placeholder="请填写房面形式" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.F_CKQK" label="查勘情况" placeholder="请填写查勘情况" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.reportConclusion" label="结论" placeholder="请填写结论" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.handleRemark" label="处理建议" placeholder="请填写处理建议" />
        <van-field :readonly="isread" v-model="houseRemoldAuthSituation.bigDate" label="大写日期" placeholder="请填写大写日期" />
        <!--<div v-for="(item, index) in ImgData" :key="index + 'ImgData'">-->
          <!--<p style="font-size: 14px">-->
            <!--{{ item.name }}-->
          <!--</p>-->
          <!--<van-uploader   @click-upload="getList(item)" :after-read="afterRead"-->
                          <!--:before-delete="delectFile" v-model="item.fileList" accept=".jpg,.gif,.png,.jpeg"-->
                          <!--multiple />-->
        <!--</div>-->
      </div>
    </van-form>
  </div>
</template>
<script>
  import {
    QuerySignCallback,
    dataTransFile,
    FileServerProxy,
    DelectFile,
    dataTransFilePreview,
    uploadFileBiz,
    selectListFile
  } from "@/utils/api";
  import { v4 as uuidv4 } from "uuid";
  export default {
    data() {
      return {
        fileHousePicture:"",
        hideMap: true,
        isread: false,
        fileLists: [],
        MapUrl: "",
        NYD: "",
        DL: "",
        JFLX: "",
        className: "",
        showPicker1: false,
        showPicker2: false,
        showPicker3: false,
        isShowTK: false,
        isShowCH: false,
        XCDC: [
          {
            name: '未做鉴定',
            key: 'isAuth',
            value:0
          },
          {
            name: '已做鉴定',
            key: 'isAuth',
            value: "",
            child: [{
              name: '不属危险房屋',
              key: 'isAuth',
              value: 1,
            }, {
              name: '观察使用',
              key: 'isAuth',
              value: 2,
            }, {
              name: '处理使用',
              key: 'isAuth',
              value: 3,
            }, {
              name: '停止使用',
              key: 'isAuth',
              value: 4,
            }, {
              name: '整体拆除',
              key: 'isAuth',
              value: 5,
            }]
          }],
        ImgData: [
          {
            name: "现场照片",
            groupGuid: "25f24d78-5483-423e-a137-21bd15fe2d08",
            fileList: [],
          },
        ],
        //存储需要传给treeSelect组件的值
        SaveCHDW: [],
        SaveTKDW: [],
        houseRemoldAuthSituation: {
          fileHousePicture:"",
          address: '',
          appraisePeopleId: '',
          authReportDate: "",
          appraiseUnitName: '',
          appraisePeopleName: '',
          reportWriteUserName: '',
          appraiseUnitNo: '',
          approvedUserId: '',
          approvedUserName: '',
          authNo: '',
          authSelect: '',
          bearingSystem: "",
          bigDate:"",
          buildArea: "",
          buildYear:"",
          authProjectName: "",
          checkUserId: "",
          checkUserName: "",
          peleaseUnit: "",
          createDate: "",
          fax:"",
          floorArea:"",
          floors:"",
          fwid: '',
          handleRemark: '',
          houseAddress: '',
          houseTo: '',
          houseUse: '',
          isAuth:'',
          objectNo:'',
          peleaseUnitId:'',
          phone:'',
          planaStructure: '',
          postCode: '',
          reportConclusion:'',
          reportNo: '',
          reportWriteUserId: '',
          reportWriteUserName: '',
          roomSurface: '',
          structureType: '',
          objectNo:'',
          fileHousePicture:''
        },
        showPickerq: false,
        showPickerq1: false,
        showPickerq2: false,
        minDate: new Date(2020, 0, 1),
        maxDate: new Date(2025, 10, 1),
        currentDate: new Date(),
        fileList: [],
        //踏勘单位
        TKDW: [],
        //测绘单位
        CHDW: [],
        valueZhen: "",
        valueZhen1: "",
        TownColumns: [],
        TownColumns1: [],
        showPickerT1: false,
        showPickerT: false,
        groupGuids: "",
        Canshu: 0,
        ENUM: {
          XB: false,
          XBARR: [],
          SF: false,
          SF1: false,
          SF2: false,
          SFARR: [],
          SFARR1: [],
          SFARR2: [],
          NYD: false,
          NYDARR: [],
          JFLX: false,
          JFLXARR: [],
          YDLX: false,
          YDLXARR: [],
          JGLX: false,
          JGLXARR: [],
          WSCLFS: false,
          WSCLFSARR: [],
          FWYT:false,
          FWYTARR: [
            {
              "DICNAME":"经营性住房",
              "DICID":1
            },
            {
              "DICNAME":"自住房",
              "DICID":2
            }
          ],
          JGLXARR: [
            {
              "DICNAME":"砌体结构",
              "DICID":"1"
            },
            {
              "DICNAME":"底部框架——上部砌体结构",
              "DICID":"2"
            },
            {
              "DICNAME":"钢筋混凝土结构",
              "DICID":"3"
            }, {
              "DICNAME":"钢结构",
              "DICID":"4"
            },{
              "DICNAME":"木(竹)结构",
              "DICID":"5"
            },
            {
              "DICNAME":"窑洞",
              "DICID":"6"
            },
            {
              "DICNAME":"混杂结构",
              "DICID":"7"
            }, {
              "DICNAME":"土木/石木结构",
              "DICID":"8"
            },
            {
              "DICNAME":"其他",
              "DICID":"99"
            }
          ],
          JGLX: false
        },
        isSaveFile: false,
        sexName: "",
        showPickerC: false,
        JGXSKJJG: "",
        rowGuid: "",
        dataRowguid: "",
        //存公司地址
        NewData: []
      };
    },
    props: {
      row: Object,
      rowDataNew: Object.rowDataNew
    },
    watch: {
      rowDataNew() {
        this.houseRemoldAuthSituation = this.rowDataNew
      },
    },
    filters: {
      inUseName: function (msg, data) {
        let name = "";
        data.forEach((item) => {
          if (item.DICID == msg) {
            name = item.DICNAME;
          }
        });
        return name;
      },
    },
    mounted() {
      this.houseRemoldAuthSituation.F_CKQK = "详见农村房屋结构安全排查登记表"
      this.houseRemoldAuthSituation.createDate=this.getNowTime()
      if (ZWJSBridge) {
        ZWJSBridge.setTitle({
          title: "鉴定报告",
        })
          .then((res) => {
          })
          .catch((err) => {
          });
      }
    },
    methods: {
      onConfirmTown(value) {
        this.JGXSKJJG = value.DICNAME;
        this.houseRemoldAuthSituation.F_JGLX = value.DICID;
        this.showPickerC = false;
      },
      //回显数据1
      //点击列表签订合同打开前端写的合同界面，先调用查询接口(接口1),判断如果有数据，就回显查询接口的合同内容。同时点击保存合同信息因调用修改接口(接口2)，如果没有数据就回显接口（接口3）的数据，
      //同时保存应掉新增接口（接口4）
      //接口1
      onConfirmRQ1(val) {
        let year = val.getFullYear();
        let month = val.getMonth() + 1;
        let day = val.getDate();
        let hour = val.getHours();
        let minute = val.getMinutes();
        let second = val.getSeconds()
        if (month >= 1 && month <= 9) {
          month = `0${month}`;
        }
        if (day >= 1 && day <= 9) {
          day = `0${day}`;
        }
        if (hour >= 0 && hour <= 9) {
          hour = `0${hour}`;
        }
        if (minute >= 0 && minute <= 9) {
          minute = `0${minute}`;
        }
        if (second >= 0 && second <= 9) {
          second = `0${second}`
        }
        this.className = "timeClass";
        this.houseRemoldAuthSituation.authReportDate = `${year}-${month}-${day}  ${hour}:${minute}:${second}`;
        this.showPickerq1 = false;
      },
      onConfirmRQ2(val) {
        let year = val.getFullYear();
        let month = val.getMonth() + 1;
        let day = val.getDate();
        let hour = val.getHours();
        let minute = val.getMinutes();
        let second = val.getSeconds()
        if (month >= 1 && month <= 9) {
          month = `0${month}`;
        }
        if (day >= 1 && day <= 9) {
          day = `0${day}`;
        }
        if (hour >= 0 && hour <= 9) {
          hour = `0${hour}`;
        }
        if (minute >= 0 && minute <= 9) {
          minute = `0${minute}`;
        }
        if (second >= 0 && second <= 9) {
          second = `0${second}`
        }
        this.className = "timeClass";
        this.houseRemoldAuthSituation.createDate = `${year}-${month}-${day}  ${hour}:${minute}:${second}`
        this.houseRemoldAuthSituation.F_TCSJ = `${year}-${month}-${day}  ${hour}:${minute}:${second}`;
        this.showPickerq2 = false;
      },

      newGuid(format) {
        //表示全局唯一标识符 (GUID)。
        function Guid(g) {
          var arr = new Array(); //存放32位数值的数组
          if (typeof g == "string") {
            //如果构造函数的参数为字符串
            InitByString(arr, g);
          } else {
            InitByOther(arr);
          }
          //返回 Guid 类的此实例值的 String 表示形式。
          this.ToString = function (format) {
            if (typeof format == "string") {
              if (
                format == "N" ||
                format == "D" ||
                format == "B" ||
                format == "P"
              ) {
                return ToStringWithFormat(arr, format);
              } else {
                return ToStringWithFormat(arr, "D");
              }
            } else {
              return ToStringWithFormat(arr, "D");
            }
          }
        }
      },
      confirmFWYT(val) {
        this.houseRemoldAuthSituation.houseUse = val.DICID
        this.ENUM.FWYT = false
      },
      confirmJGLX(val) {
        this.houseRemoldAuthSituation.structureType = val.DICID
        this.ENUM.JGLX = false
      },
      onConfirmTown(value) {
        this.JGXSKJJG = value.DICNAME;
        this.houseRemoldAuthSituation.F_JGLX = value.DICID;
        this.showPickerC = false;
      },
      //回显数据1
      //点击列表签订合同打开前端写的合同界面，先调用查询接口(接口1),判断如果有数据，就回显查询接口的合同内容。同时点击保存合同信息因调用修改接口(接口2)，如果没有数据就回显接口（接口3）的数据，
      //同时保存应掉新增接口（接口4）
      //接口1
      // onConfirmRQ1(val) {
      //   let year = val.getFullYear();
      //   let month = val.getMonth() + 1;
      //   let day = val.getDate();
      //   let hour = val.getHours();
      //   let minute = val.getMinutes();
      //   let second = val.getSeconds()
      //   if (month >= 1 && month <= 9) {
      //     month = `0${month}`;
      //   }
      //   if (day >= 1 && day <= 9) {
      //     day = `0${day}`;
      //   }
      //   if (hour >= 0 && hour <= 9) {
      //     hour = `0${hour}`;
      //   }
      //   if (minute >= 0 && minute <= 9) {
      //     minute = `0${minute}`;
      //   }
      //   if (second >= 0 && second <= 9) {
      //     second = `0${second}`
      //   }
      //   this.className = "timeClass";
      //   this.houseRemoldAuthSituation.authReportDate = `${year}-${month}-${day}  ${hour}:${minute}:${second}`;
      //   this.showPickerq1 = false;
      // },
      // onConfirmRQ2(val) {
      //   let year = val.getFullYear();
      //   let month = val.getMonth() + 1;
      //   let day = val.getDate();
      //   let hour = val.getHours();
      //   let minute = val.getMinutes();
      //   let second = val.getSeconds()
      //   if (month >= 1 && month <= 9) {
      //     month = `0${month}`;
      //   }
      //   if (day >= 1 && day <= 9) {
      //     day = `0${day}`;
      //   }
      //   if (hour >= 0 && hour <= 9) {
      //     hour = `0${hour}`;
      //   }
      //   if (minute >= 0 && minute <= 9) {
      //     minute = `0${minute}`;
      //   }
      //   if (second >= 0 && second <= 9) {
      //     second = `0${second}`
      //   }
      //   this.className = "timeClass";
      //   this.houseRemoldAuthSituation.F_TCSJ = `${year}-${month}-${day}  ${hour}:${minute}:${second}`;
      //   this.showPickerq2 = false;
      // },
      inUseName1(msg, data) {
        let name = ''
        data.forEach(item => {
          if (item.CITYCODE == msg) {
            name = item.CITYNAME
          }
        })
        return name
      },
      getData: async function () {
        // var dataGuid = "";
        // var OPTYPE = "";
        // if (this.row.NODE_GUID === '{27EE0E9F-607B-4D25-8934-3693F950C095}' || this.row.NODE_GUID === '{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}'||this.row.NODE_GUID === '{B4FCC404-5D84-4F9A-B5A2-243ECE2FB244}') {
        //   dataGuid = "68cd7dca-5812-4e11-9201-ff10b7f96d2f"
        //   OPTYPE = 2
        // }
        // else {
        //   dataGuid = "2ffd285d-f8b9-4b94-841d-ac9d7e0321e6"
        //   OPTYPE = 1
        // }
        // console.log(this.rowGuid, 'jhjhjhj')
        // var searchObjects = JSON.stringify([
        //   {
        //     field: "TO_ROW_GUID",
        //     value: this.rowGuid,
        //     operator: "=",
        //   },
        // ]);
        // let params = {
        //   accessCode: "688bd3883572440a859dfd8ba9194e7b",
        //   cityCode: window.localStorage.getItem("citycode")
        //     ? window.localStorage.getItem("citycode")
        //     : "",
        //   params: {
        //     dataguid: dataGuid,
        //     searchObject: searchObjects,
        //   },
        // };
        // const res = await QuerySignCallback(params);
        // console.log(JSON.parse(res.data.data).Data, '小何6')
        // if (JSON.parse(res.data.data).Data.length != 0) {
        //   // alert(1)
        //   this.Canshu = 0;
        //   //代表有数据
        //   this.dataRowguid = JSON.parse(res.data.data).Data[0].ROW_GUID;
        //   this.SHOWData = [];
        //   this.SHOWData.push(JSON.parse(res.data.data).Data[0]);
        //
        // } else {
        //   this.dataRowguid = this.newGuid();
        //   this.Canshu = 1;
        //   if (this.NewData.length > 0) {
        //     for(var i in this.NewData[0]){
        //       this.houseRemoldAuthSituation[i] = this.NewData[0][i]
        //     }
        //   }
        //   //督办环节 部分字段赋值
        //   if (this.row.WF_GUID == '{AFA7FC7F-BDBD-46EA-ABD2-EEF0766096D2}') {
        //     let paer1 = {
        //       procName: "up_processusername",
        //       dtParams: JSON.stringify([
        //         { I_USERID: "'" + this.row.ROW_GUID + "'", I_TYPE: 32 },
        //       ]),
        //       token: window.localStorage.getItem("token"),
        //     };
        //     let procNamesk1 = {
        //       accessCode: "69db6bece3a7480592e2ec753d1e335e",
        //       cityCode: window.localStorage.getItem("citycode")
        //         ? window.localStorage.getItem("citycode")
        //         : "441300000000",
        //       params: paer1,
        //     };
        //     const reskh1 = await FileServerProxy(procNamesk1);
        //     let data1 = eval('(' + reskh1.data.data + ')').Data
        //     if (data1.length > 0) {
        //       for (var i in data1[0]) {
        //         this.houseRemoldAuthSituation[i] = data1[0][i]
        //       }
        //     }
        //     setTimeout(()=>{
        //       if (this.$parent.formData.JDBGBH) {
        //         this.houseRemoldAuthSituation.F_BGBH = this.$parent.formData.JDBGBH
        //       }
        //       if (this.$parent.formData.FWDZ) {
        //         this.houseRemoldAuthSituation.F_FWDZ = this.$parent.formData.FWDZ
        //       }
        //     },1000)
        //   }
        //
        // }
        // console.log(this.$parent.formData.JDBGBH, '小何')
        // if (this.$parent.formData.JDBGBH) {
        //   this.houseRemoldAuthSituation.F_BGBH = this.$parent.formData.JDBGBH
        // }
        // if(this.$parent.formData.FWDZ){
        //   this.houseRemoldAuthSituation.F_FWDZ = this.$parent.formData.FWDZ
        // }
        // this.houseRemoldAuthSituation.F_CKQK = "详见农村房屋结构安全排查登记表"
        // this.houseRemoldAuthSituation.authReportDate = this.houseRemoldAuthSituation.authReportDate ? this.houseRemoldAuthSituation.authReportDate.split(" ")[0] : '';
        // this.houseRemoldAuthSituation.F_TCSJ = this.houseRemoldAuthSituation.F_TCSJ ? this.houseRemoldAuthSituation.F_TCSJ.split(" ")[0] : '';
      },
      newGuid(format) {
        //表示全局唯一标识符 (GUID)。
        function Guid(g) {
          var arr = new Array(); //存放32位数值的数组
          if (typeof g == "string") {
            //如果构造函数的参数为字符串
            InitByString(arr, g);
          } else {
            InitByOther(arr);
          }
          //返回 Guid 类的此实例值的 String 表示形式。
          this.ToString = function (format) {
            if (typeof format == "string") {
              if (
                format == "N" ||
                format == "D" ||
                format == "B" ||
                format == "P"
              ) {
                return ToStringWithFormat(arr, format);
              } else {
                return ToStringWithFormat(arr, "D");
              }
            } else {
              return ToStringWithFormat(arr, "D");
            }
          };

          //由字符串加载
          function InitByString(arr, g) {
            g = g.replace(/\{|\(|\)|\}|-/g, "");
            g = g.toLowerCase();
            if (g.length != 32 || g.search(/[^0-9,a-f]/i) != -1) {
              InitByOther(arr);
            } else {
              for (var i = 0; i < g.length; i++) {
                arr.push(g[i]);
              }
            }
          }

          //由其他类型加载
          function InitByOther(arr) {
            // var i = 32;
            // while (i--) {
            //     arr.push("0");
            // }

            var i = 32;
            while (i--) {
              arr.push(Math.floor(Math.random() * 16.0).toString(16));
            }
          }

          /*
                根据所提供的格式说明符，返回此 Guid 实例值的 String 表示形式。
                N  32 位： xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                D  由连字符分隔的 32 位数字 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
                B  括在大括号中、由连字符分隔的 32 位数字：{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
                P  括在圆括号中、由连字符分隔的 32 位数字：(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
                */

          //增加一个标识能区分开这个guid是不是由前端生成的
          function ToStringWithFormat(arr, format) {
            switch (format) {
              case "N":
                return arr.toString().replace(/,/g, "");
              case "D":
                var str =
                  arr.slice(0, 8) +
                  "-1203" +
                  "-" +
                  arr.slice(12, 16) +
                  "-" +
                  arr.slice(16, 20) +
                  "-" +
                  arr.slice(20, 32);
                str = str.replace(/,/g, "");
                return str;
              case "B":
                var str = ToStringWithFormat(arr, "D");
                str = "{" + str + "}";
                return str;
              case "P":
                var str = ToStringWithFormat(arr, "D");
                str = "(" + str + ")";
                return str;
              default:
                return new Guid();
            }
          }

          return this.ToString();
        }

        var g = new Guid();
        return g.ToString(format);
      },
      base64ImgtoFile(dataurl, filename = "file") {
        let arr = dataurl.split(",");
        let mime = arr[0].match(/:(.*?);/)[1];
        let suffix = mime.split("/")[1];
        let bstr = atob(arr[1]);
        let n = bstr.length;
        let u8arr = new Uint8Array(n);
        while (n--) {
          u8arr[n] = bstr.charCodeAt(n);
        }
        return new File([u8arr], `${filename}.${suffix}`, {
          type: mime,
        });
      },
      getNowTime: function () {
        let dateTime;
        let yy = new Date().getFullYear();
        let mm =
          new Date().getMonth() + 1 < 10
            ? "0" + (new Date().getMonth() + 1)
            : new Date().getMonth() + 1;
        let dd =
          new Date().getDate() < 10
            ? "0" + new Date().getDate()
            : new Date().getDate();
        let hh = new Date().getHours();
        let mf =
          new Date().getMinutes() < 10
            ? "0" + new Date().getMinutes()
            : new Date().getMinutes();
        let ss =
          new Date().getSeconds() < 10
            ? "0" + new Date().getSeconds()
            : new Date().getSeconds();
        dateTime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
        return dateTime;
      },
      getFile: async function () {
        this.UploadFileId = []
        this.ImgData[0].fileList = []
        let params = {
          id: this.fileHousePicture,
        }
        const res = await selectListFile(params)
        this.ImgData = res.data.data
        if (res.data.data) {
          res.data.data.forEach((item, index) => {
            console.log(item)
            // this.UploadFileId.push(item.fileId)
            // console.log(window.g.BaseURL4 + item.path + '?download=0')
            this.ImgData[0].fileList.push({
              url: window.g.BaseURL4 + item.path + '?download=0',
              isImage: true,
              fileId: item.fileId,
            })
          })
        }
        // this.ImgData.forEach((items) => {
        //   items.fileList = []
        // })
        // let groupGuid = [];
        // this.ImgData.forEach((item) => {
        //   groupGuid.push(item.groupGuid);
        // });
        // let params = {
        //   accessCode: "1fdcbce42c6d4748a020feba618d54b8",
        //   cityCode: window.localStorage.getItem("citycode")
        //     ? window.localStorage.getItem("citycode")
        //     : "",
        //   params: {
        //     groupGuid: groupGuid.join(","),
        //     toRowGuid: this.rowGuid,
        //     token: window.localStorage.getItem("token"),
        //   },
        // };
        // const res = await FileServerProxy(params);
        // let data = JSON.parse(res.data.data).FilesInfo;
        // if (data) {
        //   data.forEach((element) => {
        //     this.ImgData.forEach((items) => {
        //       if (element.GROUPGUID == items.groupGuid) {
        //         this.getFileUrl(element, items);
        //         // element["isImage"] = true;
        //         // element["url"] =
        //         //     window.g.BaseURL +
        //         //     "FileServer/api/Preview?token=" +
        //         //     window.localStorage.getItem("token") +
        //         //     "&" +
        //         //     "fileGuid=" +
        //         //     encodeURIComponent(element.ROW_GUID);
        //         // items.fileList.push(element);
        //       }
        //     });
        //   });
        // }
      },
      //获取附件文件流
      getFileUrl: async function (element, item) {
        let formData = new FormData();
        formData.append("accessCode", "98bcf528966e48ce896a8b3fd02d45d5");
        formData.append(
          "cityCode",
          window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000"
        );
        formData.append(
          "paramStr",
          JSON.stringify({
            fileGuid: element.ROW_GUID,
          })
        );
        let response = await dataTransFilePreview(formData);
        if (response) {
          // item.fileList = []
          var img = new Blob([new Int8Array(response.data, 0)], {
            type: response.headers["content-type"],
          }); //type类型可自定义
          element["isImage"] = true;
          element["url"] = window.URL.createObjectURL(img);
          item.fileList.push(element);
          console.log(item.fileList)
        }
        console.log(response)

      },
      getGsDz: async function () {
        let I_TYPE = 25
        //判断当前环节是否为困难户
        if(this.row.WF_GUID == '{B1D50CB5-FA5D-4A07-93F6-D66543EB2916}'){
          I_TYPE = 36
        }
        let paer = {
          procName: "up_processusername",
          dtParams: JSON.stringify([
            { I_USERID: "'" + this.row.ROW_GUID + "'", I_TYPE: I_TYPE },
          ]),
          token: window.localStorage.getItem("token"),
        };
        let procNamesk = {
          accessCode: "69db6bece3a7480592e2ec753d1e335e",
          cityCode: window.localStorage.getItem("citycode")
            ? window.localStorage.getItem("citycode")
            : "441300000000",
          params: paer,
        };
        const res = await FileServerProxy(procNamesk);
        this.NewData = JSON.parse(res.data.data).Data
      },
      // 保存
      save: async function (type) {

        // var dataGuid = "";
        // var OPTYPE = "";
        // if (this.row.NODE_GUID === '{27EE0E9F-607B-4D25-8934-3693F950C095}' || this.row.NODE_GUID === '{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}') {
        //   dataGuid = "68cd7dca-5812-4e11-9201-ff10b7f96d2f"
        //   OPTYPE = 2
        // }
        // else if(this.row.NODE_GUID === '{B4FCC404-5D84-4F9A-B5A2-243ECE2FB244}'){
        //   dataGuid = "68cd7dca-5812-4e11-9201-ff10b7f96d2f"
        //   OPTYPE = 2
        // }
        // else {
        //   dataGuid = "2ffd285d-f8b9-4b94-841d-ac9d7e0321e6"
        //   OPTYPE = 1
        // }
        // if (this.Canshu == 1) {
        //
        //   //新增
        //   // let uuid = uuidv4()
        //   this.SHOWData[0].ROW_GUID = this.dataRowguid; //this.$route.query.data.ROW_GUID;
        //   this.SHOWData[0].TO_ROW_GUID = this.rowGuid;
        //   this.SHOWData[0].OPTYPE = OPTYPE;
        //   //delete this.SHOWData[0].PKID;
        //   var accessCode = "00b87f486f8b11ecacdb8c8caa46b312";
        // } else {
        //   //修改
        //   var accessCode = "77ad6c1591e54d4fbc45ecc90374a2a2";
        //   this.SHOWData[0].ROW_GUID = this.dataRowguid;
        // }
        // let params = {
        //   accessCode: accessCode,
        //   cityCode: window.localStorage.getItem("citycode")
        //     ? window.localStorage.getItem("citycode")
        //     : "441300000000",
        //   params: {
        //     dataguid: dataGuid,
        //     strParams: JSON.stringify(this.SHOWData),
        //   },
        // };
        // const res = await QuerySignCallback(params);
        // if (type != '1') {
        //   if (JSON.parse(res.data.data).Success) {
        //     this.$toast.success("保存成功");
        //     this.getData()
        //   } else {
        //     this.$toast.fail("保存失败");
        //   }
        // }
      },
      CheckIsAndroid() {
        var browser = {
          versions: (function () {
            var u = navigator.userAgent,
              app = navigator.appVersion;
            return {
              //移动终端浏览器版本信息
              ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
              android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1, //android终端或uc浏览器 //u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
              iPhone: u.indexOf("iPhone") > -1, //是否为iPhone或者QQHD浏览器
              iPad: u.indexOf("iPad") > -1, //是否iPad
            };
          })(),
        };
        if (browser.versions.android) return true;
        return false;
      },
      //预览合同
      GotoPff() {
        // this.$router.push(
        //     {
        //       path:"./viewPDF",
        //       query:{
        //         data:`https://nfzjszlb.jst.zj.gov.cn/PrintServer/api/PreviewWordRpt?groupGuid=%7B4CD6F0FC-AC91-430B-B838-70DBABE0F603%7D&toRowGuid=${this.SHOWData[0].ROW_GUID}&dataGuid=2ffd285d-f8b9-4b94-841d-ac9d7e0321e6`
        //       }
        //     }
        //   )
        if (this.CheckIsAndroid()) {
          this.$router.push({
            path: "./viewPDF",
            query: {
              data:
                "https://nfzjszlb.jst.zj.gov.cn/PrintServer/api/PreviewWordRpt?groupGuid=%7B4CD6F0FC-AC91-430B-B838-70DBABE0F603%7D&toRowGuid=" +
                this.rowGuid +
                "&dataGuid=2ffd285d-f8b9-4b94-841d-ac9d7e0321e6",
            },
          });
        } else {
          ZWJSBridge.openLink({
            url:
              "https://nfzjszlb.jst.zj.gov.cn/PrintServer/api/PreviewWordRpt?groupGuid=%7B4CD6F0FC-AC91-430B-B838-70DBABE0F603%7D&toRowGuid=" +
              this.SHOWData[0].ROW_GUID +
              "&dataGuid=2ffd285d-f8b9-4b94-841d-ac9d7e0321e6",
          })
            .then((res) => {
            })
            .catch((err) => {
              window.open(
                `https://nfzjszlb.jst.zj.gov.cn/PrintServer/api/PreviewWordRpt?groupGuid=%7B4CD6F0FC-AC91-430B-B838-70DBABE0F603%7D&toRowGuid=${this.SHOWData[0].ROW_GUID}&dataGuid=2ffd285d-f8b9-4b94-841d-ac9d7e0321e6`
              );
            });
        }
      },
      // //获取相关材料
      // getList(data) {
      //   this.groupGuids = data;
      // },
      lookFile(item) {
        let url =
          window.g.BaseURL +
          "FileServer/api/Preview?token=" +
          window.localStorage.getItem("token") +
          "&" +
          "fileGuid=" +
          encodeURIComponent(item.ROW_GUID);
        if (ZWJSBridge) {
          ZWJSBridge.openLink({
            url: url,
          })
            .then((res) => {
            })
            .catch((err) => {
              window.open(url);
            });
        }
      },
      //相关材料
      afterRead(file) {
        // 此时可以自行将文件上传至服务器
        // this.getFileServerUpload(file.file);
        if (Array.isArray(file)) {
          file.forEach((item, index) => {
            this.getFileServerUpload(item.file);
          })
        } else {
          this.getFileServerUpload(file.file);
        }
      },
      blobToImg(blob) {
        return new Promise((resolve, reject) => {
          //
          let reader = new FileReader();
          reader.addEventListener("load", () => {
            let img = new Image();
            img.src = reader.result;
            img.addEventListener("load", () => resolve(img));
          });
          reader.readAsDataURL(blob);
        });
      },
      getList(item) {
        this.groupGuids = item.groupGuid;
      },
      getFileServerUpload: async function (file) {
        let formData = new FormData()
        formData.append('file', file);
        formData.append('groupName',"鉴定公司照片");
        formData.append('toGroupGuid',this.groupGuids);
        formData.append('token', window.localStorage.getItem('token'))
        const res = await uploadFileBiz(formData)
        if (res.data.data) {

          if(this.fileHousePicture){
            this.houseRemoldAuthSituation.fileHousePicture=this.fileHousePicture+","+res.data.data.id;
          }else{
            this.fileHousePicture=res.data.data.id
          }
          this.$toast.success('上传成功!')
        }
      },
      delectFile: async function (file) {
        let fileguid = "";
        if (file.ROW_GUID) {
          fileguid = file.ROW_GUID;
        } else {
          fileguid = this.fileGuid;
        }
        if (fileguid) {
          let params = {
            accessCode: "ce9b691634de4ebca68dc5bb638d07f4",
            cityCode: window.localStorage.getItem("citycode")
              ? window.localStorage.getItem("citycode")
              : "441300000000",
            params: {
              fileGuid: fileguid,
              token: window.localStorage.getItem("token"),
            },
          };
          const res = await FileServerProxy(params);
          let data = JSON.parse(res.data.data).Success;
          if (data) {
            this.$toast.success("删除成功!");
          }
        }
      },
    }
  }
</script>
<style lang="scss">
  #JDJGPDFNew {
    .subTitle {
      color: #3f8ffc;
      height: 40px;
      line-height: 40px;
      font-size: 16px;
    }

    .van-field {
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      border-bottom: 1px solid #d2d2d2;
    }
  }
</style>

